<?php

namespace XWAM\Addon\POrgDocument\Controller;

/**
 * AdvertisingContentController类
 *
 * @since 1.0 <2015-11-7> SoChishun <14507247@qq.com> Added.
 */
class AdvertisingContentController extends \XWAM\Controller\AppbaseController {

    public function content_list($advert_id = 0) {
        $list = AddonD('AdvertisingContent')->where(array('advertising_id' => $advert_id))->select();
        $this->assign('list', $list);
        $this->assign('advert_id', $advert_id);
        $this->display_cpp();
    }

    function content_edit($id = 0, $advert_id = 0) {
        $data = array();
        if ($id) {
            $data = AddonD('AdvertisingContent')->find($id);
        } else {
            $data['advertising_id'] = $advert_id;
        }
        $this->assign('data', $data);
        $this->display();
    }

    function content_edit_save() {
        $result = AddonD('AdvertisingContent')->save_content();
        $this->dialogJump($result['status'], $result['info']);
    }

    function content_delete($id = '') {
        $result = AddonD('AdvertisingContent')->delete_content($id);
        $this->ajaxReturn($result);
    }
    function change_sort($id, $sort){
        $this->ajaxReturn(AddonD('AdvertisingContent')->change_sort($id,$sort));
    }

}
